//
//  XUIPreviewImageViewInternal.h
//  etionUI
//
//  Created by wangjian on 1/28/13.
//
//

#import <UIKit/UIKit.h>

//=====================================================
//              XUIPreviewImageViewInternalCell

typedef enum
{
    EViewBrowserStyleCellDefault
}
EViewBrowserCellStyle;

@interface XUIPreviewImageViewInternalCell : UIView <UIScrollViewDelegate,UIViewExtendDelegate>
{
    CGSize _imageOriginalSize;
    UIImageView *_imageView;
    UIActivityIndicatorView *_activity;
    UIScrollView *_zoomScrollView;
}

@property (nonatomic, assign) CGSize imageOriginalSize;
@property (nonatomic, readonly) UIImageView *imageView;
@property (nonatomic, readonly) UIActivityIndicatorView *activity;
@property (nonatomic, readonly) UIScrollView *zoomScrollView;

- (id)initWithBrowserStyle:(EViewBrowserCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier;
- (void)resetViewsFrame;
- (void)resetViews;
- (void)enableActivityIndicator;
- (void)disableActivityIndicator;

@end


//=====================================================
//              XUIPreviewImageViewInternal


@class XUIPreviewImageViewInternal;
@protocol XUIPreviewImageViewInternalDelegate <NSObject>


- (NSInteger)numberOfViews:(XUIPreviewImageViewInternal *)previewImageViewInternal;

- (XUIPreviewImageViewInternalCell *)previewImageViewInternal:(XUIPreviewImageViewInternal *)previewImageViewInternal cellViewAtIndex:(NSUInteger)index;

- (void)previewImageViewInternal:(XUIPreviewImageViewInternal *)previewImageViewInternal didShowViewAtIndex:(NSUInteger)index;

- (void)previewImageViewInternal:(XUIPreviewImageViewInternal *)previewImageViewInternal didHideViewAtIndex:(NSUInteger)index;

- (void)previewImageViewInternal:(XUIPreviewImageViewInternal *)previewImageViewInternal clickViewAtIndex:(NSUInteger)index;

- (void)previewImageViewInternal:(XUIPreviewImageViewInternal *)previewImageViewInternal didScrollToNewIndex:(NSUInteger)newIndex;

@end

@interface XUIPreviewImageViewInternal : UIView <UIScrollViewDelegate>
{
@private
    UIScrollView *_scrollView;
    
    NSRange _visibelRange;
    
    NSUInteger _currentIndex;
    
    id<XUIPreviewImageViewInternalDelegate> _delegate;
    
    NSMutableDictionary *_dicCellIndex;
    
    NSComparator _sortFun;
}

@property (nonatomic, assign) NSUInteger currentIndex;
@property (nonatomic, assign) id<XUIPreviewImageViewInternalDelegate> delegate;


- (void)reloadView;
- (void)reloadCellViewAtIndex:(NSUInteger)index;
- (void)resetViewContentLocation:(UIInterfaceOrientation)toInterfaceOrientation;   //用于旋转视图时，调整界面使用

- (void)deleteCellAtIndex:(NSUInteger)index;

- (void)selectCellAtIndex:(NSUInteger)index;

- (void)enableActivityIndicatorAtIndex:(NSUInteger)index;
- (void)disableActivityIndicatorAtIndex:(NSUInteger)index;
- (void)updateCellAtIndex:(NSUInteger)index withImage:(UIImage *)image originalSize:(CGSize)size animated:(BOOL)animated;

@end
